#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

void print(vector<int> v){
    for(int i = 0; i < v.size(); i++){
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
//next_permutation 演示
void demo1(){
    vector<int> v;
    for(int i = 1; i <= 3; i++){
        v.push_back(i);
    }
    do{
        print(v);
        //next_permutation 生成字典序更大的序列
    }while(next_permutation(v.begin(), v.end()));   //如果当前为最小的字典序排序则返回false
}
//prev_permutation 演示
void demo2(){
    vector<int> v;
    for(int i = 3; i >= 1; i--){
        v.push_back(i);
    }
    do{
        print(v);
        //next_permutation 生成字典序更大的序列
    }while(prev_permutation(v.begin(), v.end()));   //如果当前为最小的字典序排序则返回false
}
void demo3(){
    vector<int> v1;
    for(int i = 1; i <= 3; i++){
        v1.push_back(i);
    }
    vector<int> v2;
    for(int i = 3; i >= 1; i--){
        v2.push_back(i);
    }
    /*
    1 2 3
    3 2 1
    */
   
    //判断第一个序列字典序是否比第二个序列的字典序小
    bool b = lexicographical_compare(v1.begin(), v1.end(), v2.begin(), v2.end());
    print(v1);
    if(b){
        cout<<"小于";
    }else{
        cout<<"大于";
    }
    cout<<endl;
    print(v2);
    cout<<"的字典序"<<endl;
}
int main(){
    demo1();
    cout<<"------------"<<endl;
    demo2();
    cout<<"------------"<<endl;
    demo3();
    return 0;
}